/*
 * This file is part of TradeHelper library.
 *
 * TradeHelper library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TradeHelper library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TradeHelper library.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.rag.forum.ui;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

/**
 * User: mgarin Date: 12.04.12 Time: 18:19
 */

public class ItemTransferable implements Transferable
{
    private String itemId;

    public ItemTransferable ( String itemId )
    {
        super ();
        this.itemId = itemId;
    }

    public DataFlavor[] getTransferDataFlavors ()
    {
        return new DataFlavor[]{ DataFlavor.stringFlavor };
    }

    public boolean isDataFlavorSupported ( DataFlavor flavor )
    {
        return flavor != null && flavor.equals ( DataFlavor.stringFlavor );
    }

    public Object getTransferData ( DataFlavor flavor )
            throws UnsupportedFlavorException, IOException
    {
        if ( flavor.equals ( DataFlavor.stringFlavor ) )
        {
            return itemId;
        }
        else
        {
            return null;
        }
    }
}